Skip to content

gh-116541: Handle errors correctly in _pystatvfs_fromstructstatvfs#116542

Merged
sobolevn merged 1 commit into
python:mainfrom
sobolevn:issue-116541
Mar 12, 2024
Merged

gh-116541: Handle errors correctly in _pystatvfs_fromstructstatvfs#116542
sobolevn merged 1 commit into
python:mainfrom
sobolevn:issue-116541

Conversation

@sobolevn

@sobolevn sobolevn commented Mar 9, 2024

Copy link
Copy Markdown
Member

Comment thread Modules/posixmodule.c
Comment on lines +12997 to +12998
SET_RESULT(PyLong_FromLong((long) st.f_bsize));
SET_RESULT(PyLong_FromLong((long) st.f_frsize));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that some code is the same in both branches.

Also, on Linux some of fields are defined as unsigned long instead of long. Did not check other Posix systems. There may be a problem, but this is another issue.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I found this:

struct statvfs {
               unsigned long  f_bsize;    /* Filesystem block size */
               unsigned long  f_frsize;   /* Fragment size */
               fsblkcnt_t     f_blocks;   /* Size of fs in f_frsize units */
               fsblkcnt_t     f_bfree;    /* Number of free blocks */
               fsblkcnt_t     f_bavail;   /* Number of free blocks for
                                             unprivileged users */
               fsfilcnt_t     f_files;    /* Number of inodes */
               fsfilcnt_t     f_ffree;    /* Number of free inodes */
               fsfilcnt_t     f_favail;   /* Number of free inodes for
                                             unprivileged users */
               unsigned long  f_fsid;     /* Filesystem ID */
               unsigned long  f_flag;     /* Mount flags */
               unsigned long  f_namemax;  /* Maximum filename length */
           };

My proposal:

  • Let's keep this PR focused on a new error handling
  • I will open a new issue about this and do more research: why is it like this
  • Probably I will send a second PR fixing the type

Since posixmodule is rather hard, I would prefer not to do any semantic changes now.

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are going to backport this change, you can merge it first. Otherwise it is better to wait until the other issue be solved.

@sobolevn

Copy link
Copy Markdown
Member Author

I am going to backport this change, like all others. Thanks a lot for finding this and reviewing my PRs! 👍

Here's a link for the statvfs issue: #116642

@sobolevn sobolevn merged commit f8147d0 into python:main Mar 12, 2024
@miss-islington-app

Copy link
Copy Markdown

Thanks @sobolevn for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 12, 2024
…tvfs` (pythonGH-116542)

(cherry picked from commit f8147d0)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
@bedevere-app

bedevere-app Bot commented Mar 12, 2024

Copy link
Copy Markdown

GH-116643 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.12 only security fixes label Mar 12, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 12, 2024
…tvfs` (pythonGH-116542)

(cherry picked from commit f8147d0)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
@bedevere-app

bedevere-app Bot commented Mar 12, 2024

Copy link
Copy Markdown

GH-116644 is a backport of this pull request to the 3.11 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.11 only security fixes label Mar 12, 2024
sobolevn added a commit that referenced this pull request Mar 12, 2024
…atvfs` (GH-116542) (#116643)

gh-116541: Handle errors correctly in `_pystatvfs_fromstructstatvfs` (GH-116542)
(cherry picked from commit f8147d0)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
sobolevn added a commit that referenced this pull request Mar 12, 2024
…atvfs` (GH-116542) (#116644)

gh-116541: Handle errors correctly in `_pystatvfs_fromstructstatvfs` (GH-116542)
(cherry picked from commit f8147d0)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 25, 2024
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants